package model;

import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.util.ArrayList;

public class ArrayQueue<E> extends AdapterQueue<E> implements Prediction<E>{
	
int size = 1;
private ArrayList<Integer> xCo; 
private boolean predictPressed = false;
	
	public void setSize(int i){
		size = i;
	}
	public int getSize(){
		return size;
	}
	public ArrayList<Integer> getxCo(){
		return xCo;
	}
	
	public void paint(Graphics g) {
		
		 xCo = new ArrayList<Integer>();
	     int x = 150;
	     int y = 300;
	     int h = 60;
	     int w = 60;
	     
	     g.setFont(new Font("",0,15));
		 g.drawString("Array Queue Mode", 10, 20);
		 
	     g.setFont(new Font("",0,20));     
	     g.drawString("Head", x-56, y+40);
	     
	     for(int i = 0; i < size; i++){
	         g.drawRect(x, y, w, h);
	         g.drawString(String.valueOf(i),x+25,y-10);
	         x = x + w +10;
	     }
	     x=150;
		
		if(!S.isEmpty()){
			
			 g.setFont(new Font("",0,50));
		     FontMetrics fm = null;
		     fm = g.getFontMetrics();
		 
		     g.setColor(new Color(0,0,0,200));
		     
				for(int i=0; i< S.size(); i++){
					xCo.add(x);
				    String s = (String) S.get(i);
				    g.drawRect(x, y, w, h);
				    g.drawString(s,(((w - fm.charWidth(s.charAt(0)))/2)+x), (y + 47 ));
				    x = x + w +10;	
				    
			     }	
				  if(predictPressed==true){
					  xCo.add(x);		  
				  }
				  
			predictPressed =false;				
		}	
		
		g.setFont(new Font("",0,20));
		
	     if(size() < size){ 
	    	 g.drawString("Tail", x+15, y+h + 22);
	     }
	     else{
	    	 g.drawString("Full", x+2, y+40);	 
	     }
		
	}
	@Override
	public boolean predictAdd(int guess) {
		if(guess == S.size()){
			return true;
		}
		else{
			return false;
		}
	}
	@Override
	public boolean predictRemove(int guess) {
		if(guess==0){
			return true;
		}
		else{
			return false;
		}
	}
	@Override
	public void setPressed(boolean b) {
		predictPressed=b;
	}

}
